import numpy as np
import csv

def main():
	infile = 'features_scaleHist_10_0.0001.csv'
	inf = open(infile, 'r')
	reader = csv.reader(inf)
	
	outf = open(infile + '.stats', 'w')
	featurecount2count = dict()
	for row in reader:
		introw = np.array(row).astype(np.int)
		for ele in introw:
			if ele == 0:
				continue
			if ele in featurecount2count:
				featurecount2count[ele] = featurecount2count[ele] + 1
			else:
				featurecount2count[ele] = 1

	for key,value in sorted(featurecount2count.items()):
		outf.write(str(key) + ',' + str(value) + '\n')

	outf.close()

if __name__=="__main__":
	main()
